AddPersonWindow = function(){
	var this_window = this;
	var save = function(){
		if(!form.form.isValid()){
			return false;
		}
		var params = form.form.getFieldValues();
		Ajax({
			url : "person/save.action",
			params : params,
			maskTarget : this_window,
			window : this_window,
			grid :personPanel
		});
	};
	this.listeners = {
			hide : function(){
				form.form.reset();
			},
			show : function(){
				Ext.Ajax.request({
					url: "person/getMaxId.action",
					success : function(resp){
						var obj = Ext.decode(resp.responseText);
						if(obj.status===true){
							form.idText.setValue(obj.id);
						}
					}
				});
			}
		};
	var form = new Ext.form.FormPanel({
		frame : true,
		padding : 5,
		labelAlign : "right",
		labelWidth : 60,
		defaults : {
			labelAlign : "right",
			labelWidth : 60,
			defaults : {
				xtype : "textfield",
				anchor : "95%"
			}
		},
		items : [{
			xtype : 'fieldset',
			title : "员工信息",
			items : [{
				xtype : "numberfield",
				fieldLabel : "员工编号",
				name : "person.id",
				ref : "../idText",
				allowDecimals : false,
				allowNegative : false
			},{
				fieldLabel : "员工姓名",
				name : "person.name",
				allowBlank : false
			},{
				xtype : "hidden",
				name : "person.password",
				value : MD5("000000")
			}]
		},{
			xtype : 'fieldset',
			html : "<font color='blue'>编号会自动生成，也可输入，可以为空。密码默认为000000，创建后请尽快修改。</font>"
		}]
	});
	AddPersonWindow.superclass.constructor.call(this, {
		title : "创建员工账号",
		iconCls : "user_add",
		width : 350,
		border : false,
		autoHeight : true,
		closeAction : "hide",
		modal : true,
		items : [form],
		buttons : [{
			text : "保存",
			handler : save
		},{
			text : "取消",
			handler : function(){
				this_window.hide();
			}
		}]
	});
};
Ext.extend(AddPersonWindow, Ext.Window);
var addPersonWindow = new AddPersonWindow();